
! This is for splitting the results into more plot friendly formats (esp xmgrace)
! SWH 2011

program data_split

implicit none

real(8)    :: time, evar, pvar, wvar
integer    :: temp_file=10
integer    :: etemp=11
integer    :: ptemp=12
integer    :: wtemp=14
integer    :: tstep, ios
character  :: junk

open(temp_file,FILE='../results/temperature.txt',STATUS='OLD')
open(etemp,FILE='../results/etemp.txt',STATUS='UNKNOWN')
open(ptemp,FILE='../results/ptemp.txt',STATUS='UNKNOWN')
open(wtemp,FILE='../results/wtemp.txt',STATUS='UNKNOWN')

read(temp_file,*) junk

do
  read(temp_file,*,iostat=ios) tstep, time, evar, pvar, wvar
  if (is_iostat_end(ios)) then
    close(temp_file)
    close(etemp)
    close(ptemp)
    close(wtemp)
    print *, "Data splitting complete"
    stop
  endif
  write(etemp,*) time, evar
  write(ptemp,*) time, pvar
  write(wtemp,*) time, wvar
enddo

end program data_split
